/*
 * CChatMsgDispatcher.h
 *
 *  Created on: 2012-7-17
 *      Author: guanlei
 */

#ifndef CCHATMSGDISPATCHER_H_
#define CCHATMSGDISPATCHER_H_

#include "../common/queue.h"
#include "../common/MD5.h"
#include "../net/msg.h"
#include "../net/epoll_socket.h"
#include "../net/thread.h"
#include "../net/IMsgDispatcher.h"
#include "Message.h"
#include "CChater.h"
#include "CChatWorld.h"
#include "IChannel.h"
#include <string>
#include <sstream>

using namespace omg;

//const char* public_key = "sdfs311ksI";
extern char* public_key;
class CChatMsgDispatcher:public IMsgDispatcher,public Thread {
public:
	CChatMsgDispatcher();
	~CChatMsgDispatcher();
	virtual	void 	add_msg_to_queue(MsgBase*,EPollSocket* socket=0);
	virtual void	dispatch_msg();
	virtual void*	on_run(void);
	bool 		do_login(MsgBase*,EPollSocket* socket);
	bool 		check_msg_validae(MsgBase*,EPollSocket* socket);
	void		send_login_default_msg(EPollSocket*);
	bool		validate_login(ChaterLoginChatChannel*);
	void 		do_logout(CHATER_ID chater_id);
	void 		process_chat_msg(UserChatMsg*);
private:
	omg::WRQueue<MsgBase,MutexLock>	_msg_queue;
};

#endif /* CCHATMSGDISPATCHER_H_ */
